function outs=f(m)
    global px
    global iy
    global errorout
    px=m(1);
    iy=m(2);
    
    sim('farzad009MotorPIDOptimization');
    
    m1=size(errorout);
    m1=m1(1);
    test=0;
    outs=m1;
    for i=m1:-1:1
        if (abs(errorout(i))>0.1 & test==0)
            outs=i;
            test=1;
        end
    end
    outs
    